<?php
namespace Home\Controller;
use Think\Controller;
class MyorderController extends BaseController {

   
    public function bd_order()
    {   
       
      $key=I('key');

        if($key&&$key!=""){
           /* $map1 = array(
                'id' =>array('eq', $key),
                'desc'=>array('like', "%".$key."%"),                
                '_logic'     =>'or',
            );*/
            $map['desc']=array('like', "%".$key."%");
            
        }


      $map['user_id']=session('user.id');
      //var_dump($map);exit();
     // $Nowpage = $_GET['p']?$_GET['p']:1;
      $count      = M('order')->where($map)->count();
      /*$pageSize=10;
        $Page = getHomepage($count,$pageSize);
      $show       = $Page->show();*/

        $orders=M('order')->where($map)->order('addtime desc')->select();
        //$orders=M('order')->where($map)->page($Nowpage,$pageSize)->order('addtime desc')->select();
       $this->assign('orders',$orders)->assign('orderNum',$count)/*->assign('page',$show)*/->display();
    }


      public function gz_order()
    {   
     
      $map['user_id']=session('user.id');
      $userid=session('user.id');

      //$Nowpage = $_GET['p']?$_GET['p']:1;
      $count   = M('order_gz')->where($map)->count();
      /*$pageSize=15;
      $Page = getHomepage($count,$pageSize);
      $show = $Page->show();*/
      //$orders=M('order_gz')->where($map)->page($Nowpage,$pageSize)->order('addtime desc')->select();
      $orders=M('order_gz')->where($map)->order('addtime desc')->select();

       $this->assign('orders',$orders)->assign('orderNum',$count)->display();
    }



    public function addorder ()
    {   

        if (!IS_POST)
        {
        
           $this->assign('orders',$orders)->display();
        }
        else
        {   $userid= session('user.id');
            $data=$_POST;
            $data['addtime'] = time();
            $data['user_id'] = $userid;
            $data['invite_id'] = M('user')->where("id=$userid")->getField('invite_id');
            $res=M('order')->add($data);
            if ($res) {
              $this->success("下单成功,等待审核",U('Order/order_process'));
            }
        }

    }


    public function order_hf()
    {
      $map['order_id']=I('get.id');
      $id=I('get.id');
     $orderinfo= M('order')->find($id);
     $order_code=$orderinfo['order_code'];
     $list= M('order_fh')->where($map)->select();
      $map2['order_id']=I('get.id');
      $map2['status']=1;

     $fh_list= M('order_fh')->where($map2)->select();
     //var_dump($list);exit();
     $fh_open=M('jifen')->getField('fh_open');
      $this->assign('list',$list)->assign('order_code',$order_code)->assign('fh_open',$fh_open)->assign('fh_list',$fh_list)->display();
    }

     public function gz_hf()
    {
      $map['gz_id']=I('get.id');
     $list= M('order_gz_hf')->where($map)->select();
      $this->assign('list',$list)->display();
    }

}
